package com.wangsh.usersCenter.users.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import com.wangsh.usersCenter.common.pojo.BasePojo;
/**
 * 菜单表
 * @author 王晨曦
 */
public class AMenu extends BasePojo<AMenu>
{	
	/* 主键,自动递增 */
	private int id;
	/* 管理员创建id */
	private int createId;
	/* 管理员更新id */
	private int updateId;
	/* 上一级菜单Id */
	private int parentId;
	/* 名称 */
	private String name;
	/* 菜单的Url,权限验证的时候使用 */
	private String url;
	/* 内容:描述 */
	private String content;
	/* 是否为叶子节点:0:非叶子(有儿子),1:叶子(没有子节点) */
	private byte isLeafStatus;
	/* 状态:0:禁用,1:启用 */
	private byte status;
	/* 创建时间 */
	private Date createTime;
	/* 更新时间 */
	private Date updateTime;
	/* 发布时间:用来排序 */
	private Date pubTime;
	
	private AMenu parentMenu;
	
	//表示树形结构打开的数据
	private  boolean open;
	//表示子节点
	private List<AMenu> children =new ArrayList<>();
 
	private String statusStr;
	private String isleafStr;
	/* 根据角色id和菜单id查询角色菜单表,
	 * 0:木有查询到结果,1:查询到结果 */
	private AAdmins createAdmins;
	private AAdmins updateAdmins;
	
	private boolean roleMenuFlag; 
	/*
	 * 方便枚举项在网页上显示出来 键为值(数字), 值为字符串描述 只提供get方法
	 */
	private Map<String,String> enumsMap = new TreeMap<String, String>();
	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		AMenuEnum[] menuEnums = AMenuEnum.values();
		for (int i = 0; i < menuEnums.length; i++)
		{
			AMenuEnum menuEnum = menuEnums[i];
			String key = menuEnum.toString() ; 
			enumsMap.put(key + "-" + menuEnum.getStatus() + "", menuEnum.getName());
		}
		return enumsMap;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getCreateId()
	{
		return createId;
	}

	public void setCreateId(int createId)
	{
		this.createId = createId;
	}

	public int getUpdateId()
	{
		return updateId;
	}

	public void setUpdateId(int updateId)
	{
		this.updateId = updateId;
	}

	public int getParentId()
	{
		return parentId;
	}

	public void setParentId(int parentId)
	{
		this.parentId = parentId;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getUrl()
	{
		return url;
	}

	public void setUrl(String url)
	{
		this.url = url;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public byte getIsLeafStatus()
	{
		return isLeafStatus;
	}

	public void setIsLeafStatus(byte isLeafStatus)
	{
		this.isLeafStatus = isLeafStatus;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public String getStatusStr()
	{
		/* 获取所有的枚举项 */
		AMenuEnum[] AUserMenuEnums = AMenuEnum.values();
		for (int i = 0; i < AUserMenuEnums.length; i++)
		{
			AMenuEnum AUserMenuEnum = AUserMenuEnums[i];
			/* 因为枚举项可能有好多,所以需要加一个判断 */
			if (AUserMenuEnum.toString().startsWith("STATUS_"))
			{
				if (AUserMenuEnum.getStatus() == this.getStatus())
				{
					this.statusStr = AUserMenuEnum.getName();
				}
			}
		}
		return statusStr;
	}

	public String getIsleafStr()
	{
		/* 获取所有的枚举项 */
		AMenuEnum[] AUserMenuEnums = AMenuEnum.values();
		for (int i = 0; i < AUserMenuEnums.length; i++)
		{
			AMenuEnum AUserMenuEnum = AUserMenuEnums[i];
			/* 因为枚举项可能有好多,所以需要加一个判断 */
			if (AUserMenuEnum.toString().startsWith("ISLEAF_"))
			{
				if (AUserMenuEnum.getStatus() == this.getIsLeafStatus())
				{
					this.isleafStr = AUserMenuEnum.getName();
				}
			}
		}
		return isleafStr;
	}

	public List<AMenu> getChildren()
	{
		return children;
	}

	public void setChildren(List<AMenu> children)
	{
		this.children = children;
	}

	public boolean isOpen()
	{
		return open;
	}

	public void setOpen(boolean open)
	{
		this.open = open;
	}

	public boolean isRoleMenuFlag()
	{
		return roleMenuFlag;
	}

	public void setRoleMenuFlag(boolean roleMenuFlag)
	{
		this.roleMenuFlag = roleMenuFlag;
	}

	public AMenu getParentMenu()
	{
		return parentMenu;
	}

	public void setParentMenu(AMenu parentMenu)
	{
		this.parentMenu = parentMenu;
	}

	public AAdmins getCreateAdmins()
	{
		return createAdmins;
	}

	public void setCreateAdmins(AAdmins createAdmins)
	{
		this.createAdmins = createAdmins;
	}

	public AAdmins getUpdateAdmins()
	{
		return updateAdmins;
	}

	public void setUpdateAdmins(AAdmins updateAdmins)
	{
		this.updateAdmins = updateAdmins;
	}

	
	
}
